package com.lzw.breezeNovel.webApp.controller.video;


import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.model.entity.query.PaginationResultQuery;
import com.lzw.breezeNovel.model.entity.query.video.ShortVideoQuery;
import com.lzw.breezeNovel.webApp.service.video.ShortVideoService;
import com.lzw.breezeNovel.webApp.vo.video.ShortVideoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller.video
 * @date 2025/3/23
 * @description 短视频
 */
@RestController
@RequestMapping("/app/shortVideo")
@SuppressWarnings("all")
public class ShortVideoController {

    /**
     * 注入service
     */
    @Autowired
    private ShortVideoService shortVideoService;

    /**
     * 添加短视频
     */
    @RequestMapping("/addShortVideo")
    public Result addShortVideo(@RequestBody ShortVideoQuery shortVideoQuery) {
             shortVideoService.addShortVideo(shortVideoQuery);
             return Result.ok();
    }

    /**
     * 分页获取所有的短视频
     */
    @RequestMapping("/getAllShortVideo")
    public Result<PaginationResultQuery<ShortVideoVo>> getAllShortVideo(@RequestParam Integer pageNo, @RequestParam Integer size) {
        PaginationResultQuery<ShortVideoVo> shortVideoVoPaginationResultQuery = shortVideoService.getAllShortVideo(pageNo, size);
        return Result.ok(shortVideoVoPaginationResultQuery);
    }

    /**
     * 更新分享次数
     */
    @RequestMapping("/updateShareCount")
    public Result updateShareCount(@RequestParam Long videoId, @RequestParam Long userId) {
        shortVideoService.updateShareCount(videoId, userId);
        return Result.ok();
    }

    /**
     * 更新播放次数
     */
    @RequestMapping("/updatePlayCount")
    public Result updatePlayCount(@RequestParam Long videoId) {
        shortVideoService.updatePlayCount(videoId);
        return Result.ok();
    }

    /**
     * 获取当前用户的所有的作品
     */
    @RequestMapping("/getMyAllShortVideo")
    public Result<PaginationResultQuery<ShortVideoVo>> getMyAllShortVideo(@RequestParam Integer pageNo, @RequestParam Integer size) {
        PaginationResultQuery<ShortVideoVo> shortVideoVoPaginationResultQuery = shortVideoService.getAllVideoByUserId(pageNo, size);
        return Result.ok(shortVideoVoPaginationResultQuery);
    }

    /**
     * 删除作品
     */
    @DeleteMapping("/deleteShortVideo")
    public Result deleteShortVideo(@RequestParam Long videoId) {
        shortVideoService.deleteShortVideo(videoId);
        return Result.ok();
    }


}
